Skip to content

Conversation

@Tsapen
Copy link

@Tsapen Tsapen commented Nov 2, 2019

Добавлены сортировка, фильтры и логирование

Copy link
Collaborator

@penguinlav penguinlav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не большое преревью :)



def select_all(sort_by, filter_field, filter_value):
with open("data.json", 'r', encoding='utf-8')as file:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Перекрываешь встроенный метод file и странно, что в пепе нет пробела перед as, так себе выглядит :)

Comment on lines +97 to +102
with open("data.json", 'r', encoding='utf-8')as file:
data = json.loads(file.read())
try:
del data[str(id_flight)]
with open("data.json", 'w', encoding='utf-8')as file:
json.dump(data, file, ensure_ascii=False, indent=4)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почитай https://ru.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself и подумай, как бы круто код выглядел, вынеси ты общение с бд (файлом) в отдельный класс.

Comment on lines +18 to +19
2019-11-02 19:40:15,797 - flask.app - INFO - {'url': 'http://localhost:5000/update_flight', 'args': {}, 'body': {'id_flight': '3', 'flight': {'departure_time': 1600, 'arrival_time': '17:00', 'travel_time': '01:00', 'destination_airport': 'Vnukovo', 'type_aircraft': 'TU'}}, 'req_method': 'PUT', 'duration': 0.003, 'response': <Response 77 bytes [400 BAD REQUEST]>, 'http_status': 400}
2019-11-02 19:40:15,797 - werkzeug - INFO - 127.0.0.1 - - [02/Nov/2019 19:40:15] "PUT /update_flight HTTP/1.1" 400 -
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все еще скудное журналирование. Как я по этому логу пойму из-за чего, четырехсотка? Этот лог увидит только админ, админ должен понимать что творит сервис без чтения кода. Нормальная тема, когда сервис гигабайты логов в день генерируют, именно для этого есть такое, как "ротация логов". Да, и фича с уровнем логгирования. Когда без изменения кода можно включить дополнительный уровень логов. Пока не зачет :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants